package com.example.springcloudAlibaba.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author hanjc
 */
@RestController
@RequestMapping("/consumer")
public class Controller {

    private final String paymentURl = "http://nacos-payment-provider/springcloud-alibaba/payment";
    @Resource
    private RestTemplate restTemplate;
    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/payment/nacos")
    public String testLinkToPayment() {

        return restTemplate.getForObject(paymentURl + "/nacos", String.class);
    }

    @GetMapping("/testnacos")
    public String testNacos() {

        return "hello nacos\n" + serverPort + "\n" + new Date();

    }

}
